package com.java.order.orderweb.dao;

import com.java.order.orderweb.mapper.OrderMapper;
import com.java.order.orderweb.pojo.Order;
import com.java.order.orderweb.pojo.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;

/**
 * @ClassName OrderDao
 * @Description 订单具体实现，后期接口接入可随时更换数据库
 * @Author Trigger Wu
 * @Date 2018/9/20 10:47
 * @Version 1.0
 **/
public class OrderDao implements IOder {
    @Autowired
    private OrderMapper orderMapper;

    //添加订单信息
    public void createOrder(Order order) {
        orderMapper.save(order);
    }

    public Order queryOrderById(String orderId) {
        return null;
    }

    public ResultMsg changeOrderStatus(Order order) {
        try {
            order.setUpdateTime(new Date());
            this.orderMapper.update(order);
        } catch (Exception e) {
            e.printStackTrace();
            return new ResultMsg("500", "更新订单出错!");
        }
        return new ResultMsg("200", "更新成功!");
    }
}
